#ifndef LISTCROSS_H_
#define LISTCROSS_H_

// Judge list cross
template<class TData> struct ListStruct
{
	ListStruct* nextNode;
	ListStruct* previousNode;
	TData itsData;
};

/**
* To judge whether two lists are crossed
*/
template<class TData>
bool isListCrossed(ListStruct<TData>* firstList, ListStruct<TData>* secondList)
{
	ListStruct<TData>* firstListPtr = NULL;
	while(NULL != firstList)
	{
		firstListPtr = firstList;
		firstList = firstList->nextNode;
	}

	ListStruct<TData>* secondListPtr = NULL;
	while(NULL != secondList)
	{
		secondListPtr = secondList;
		secondList = secondList->nextNode;
	}
	return (NULL != firstListPtr && NULL != secondListPtr && secondListPtr == secondListPtr);
}

template<class TData>
ListStruct<TData>* findListCrossedNode(ListStruct<TData>* firstList, ListStruct<TData>* secondList)
{
	ListStruct<TData>* firstListPtr = firstList;
	ListStruct<TData>* secondListPtr = secondList;

	int firstListLength = 0;
	int secondListLength = 0;
	while (NULL != firstList)
	{
		++firstListLength;
		firstList = firstList->nextNode;
	}
	while (NULL != secondList)
	{
		++secondListLength;
		secondList = secondList->nextNode;
	}

	if (firstListLength > secondListLength)
	{
		// not finished	
	
	}
}

#endif